var param={};
var exportparam={}; 
//从业务设置中获取是否启用序列号
var myPage;
 
// 列表配置
function table_init() {
	  
	var page_colmodel=new Array();
	 
	page_colmodel.push({
		display : '序号',
		name : 'xh',
		width : '30',
		isNo : true 
	});  
	page_colmodel.push({
		display : '操作',
		name : 'jl_code',  
		isHide : false,
		align : 'center',
		replaceHtmlFunction:'replaceHtml',
		width : '70'
	});
	page_colmodel.push({
		display : '交路信息',
		name : 'jl_name',  
		align : 'left',
		width : '180'
	});
	page_colmodel.push({
		display : '车次',
		name : 'cc',  
		align : 'left',
		width : '80'
	}); 
	page_colmodel.push({
		display: '顺序',
		name : 'orderby',
		isConfigurable : true,
		isHide : false, 
		width : '60'
	}); 
	page_colmodel.push({
		display: '车型',
		name : 'cx',
		isConfigurable : true,
		isHide : false,
		align : 'center',
		width : '60'
	});
	page_colmodel.push({
		display: '始发站',
		name : 'city1',
		isConfigurable : true,
		isHide : false,
		align : 'left',
		width : '80'
	});
	page_colmodel.push({
		display : '到达站',
		name : 'city2', 
		isConfigurable : true,
		isHide : false,
		align : 'left', 
		width : '80'
	});
	 
	page_colmodel.push({
		display: '始发时间',
		name : 'time1',
		isConfigurable : true,
		isHide : false, 
		width : '60'
	});
	page_colmodel.push({
		display: '到达时间',
		name : 'time2',
		isConfigurable : true,
		isHide : false, 
		width : '60'
	});
	
	var page = {
		id : "cc",		
		keycol:"cc",
		url : "ccgljson_loadtablelist.action",
		dataType : 'json',
		colModel : page_colmodel, 
		sortname : "cc",
		sortorder : "asc",
		usepager : true,
		useRp : true,
		rp : 50,
		showTableToggleBtn : false,
		width : 'auto',
		height : 'auto', 
		selectrow:'selectrow',
		setPageParams : 'list_getPageParams()',
		detailRowNumber : 5
	};
	myPage = page;
	$("#resultList").flexigrid(page);
}

function selectrow(row) {
	formSearchgx(row.cc);
}

function replaceHtml(i) {
	var data = getData(i);
	// 商品停用
	if((data.jl_code==null || data.jl_code=="") && data.cc !="0D出库" && data.cc !="0D入库")
	{
		return '<a href="javascript:;" class="operate edit"  onclick="editRecord('+ i +')"></a><a href="javascript:;" class="operate del"  onclick="deleteRecord('+ i +')"></a>';
	}
	else
	{
		return '<a href="javascript:;" class="operate edit" onclick="editRecord('+ i +')"></a>';
	}
}
// 编辑商品
function editRecord(i) { 
	var data = getData(i);
	var tabname = "车次编辑";
	var text = "车次编辑";
	var href = top.urlpath + "/ccgl_toupdate.action?cc=" + data.cc; 
	top.maincontab.opentabs(href,text,"0",tabname); 
}
  
function deleteRecord(i) { 
	var data = getData(i);
	 
	layer.confirm("确认删除车次"+data.cc+"吗？", {
		  btn: ['确定','取消'] //按钮
		}, function(){
			var param = {};
			param["cc"] = data.cc; 
			$.post(top.urlpath + "/ccgljson_deletetablelist.action", param, function(result, resultState) {
				if (result.state == "0") {
					top.showSuccessMsg("删除成功");  
					layer.closeAll(); 
					$("#resultList").flexReload(myPage); 
				}else
				{
					top.showErrorMsg("删除失败");   
				} 
			});
		}); 
} 
   
//列表----获取查询参数
function list_getPageParams() {
	//高级搜索
	var params = [ 
	{
		name : 'keyword',
		value : $("#keyword").val()
	},
	{
		name : 'querytype',
		value : $("#querytype").val()
	},
	{
		name : 'search_a',
		value : $("#search_a").val()
	},
	{
		name : 'search_b',
		value : $("#search_b").val()
	}, 
	{
		name : 'search_c',
		value : $("#search_c").val()
	}];
	exportparam=params;
	return params;
}